﻿using System;
using System.Web;

namespace YN.Core
{
    public class ErrorModule: IHttpModule
    {
        #region IHttpModule 成员

        public void Dispose() { }

        public void Init(HttpApplication context)
        {
            context.Error += new EventHandler(ContextError);
        }

        #endregion

        private void ContextError(object sender, EventArgs e)
        {
            HttpContext ctx = HttpContext.Current;

            Exception ex;

            for (ex = ctx.Server.GetLastError(); ex.InnerException != null; ex = ex.InnerException) { }

            if (ex is HttpException && ((HttpException)ex).ErrorCode == 404)
            {
                //TODO
            }
        }
    }
}
